﻿    using System;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using NHibernate.Tool.hbm2ddl;

namespace PhotoBook.Test
{
    /// <summary>
    /// Deve verificar se o esquema de banco de dados é gerado automaticamente.
    /// </summary>
    [TestClass]
    public class Gera_Esquema_De_Configuracao_NHibernate 
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestInitialize()]
        public void Copiar_Banco_De_Dados()
        {
            string copiarBancoPara = System.IO.Path.Combine(testContextInstance.TestDeploymentDir, "BookDataBase.sdf");
            string copiarBancoDe = System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetParent(testContextInstance.TestDir).FullName).FullName, "PhotoBook.Model\\BookDataBase.sdf");
            System.IO.File.Copy(copiarBancoDe, copiarBancoPara, true);           
        }

        [TestMethod]
        public void Verifica_Se_NHibernate_Configura()
        {
            var config = new NHibernate.Cfg.Configuration();
            config.Configure(typeof(PhotoBook.Model.Entities.Album).Assembly, "PhotoBook.Model.Hibernate.cfg.xml");         
            config.AddAssembly(typeof(PhotoBook.Model.Entities.Album).Assembly);
            new SchemaExport(config).Execute(false, true, false);
        }
    }
}
